<template>
  <div class="full-box shadow-box padding-box">
    <OperateCollection
      :showAdd="true"
      @search="initData"
      @add="linkTo(`commonForm/${tableName}/0`)"
    >
      <template #condition>
        <div class="condition-item">
          <el-input
            v-model="queryParams.project_name"
            placeholder="按项目名称关键字查询"
            clearable
          ></el-input>
        </div>
        <div v-if="isAdmin == 1" class="condition-item">
          <DeptCascader
            :options="dept"
            :defaultChecked.sync="queryParams.responsible_unit_id"
            @change="changeDept"
          ></DeptCascader>
        </div>
      </template>
    </OperateCollection>
    <div class="table-wrapper">
      <BaseTable
        :columns="columns"
        :showSort="true"
        :tableData="tableData"
        :pages="{
          show: true,
          count: count,
        }"
        :operate="{
          show: true,
          width: 150,
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button
            type="primary"
            size="mini"
            @click="linkTo(`commonForm/${tableName}/${current.row.id}`)"
            >详情</el-button
          >
        </template>
      </BaseTable>
    </div>
  </div>
</template>

<script>
import BaseTable from "@/components/Common/BaseTable.vue";
import OperateCollection from "./components/OperateCollection.vue";
import LinkTo from "@/mixins/LinkTo";
import { getManagerChangeList } from "@/api/WorkCollection/Index";
import commonList from "@/mixins/commonList";
import DeptCascader from "@/components/Common/DeptCascader.vue";
import queryItem from "./components/queryItem";
export default {
  mixins: [LinkTo, commonList, queryItem],
  components: { BaseTable, OperateCollection, DeptCascader },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        check_status: "",
          project_id:'',
        project_name: "",
        responsible_unit_id: "",
      },
      tableName: "t_person_change",
    };
  },
  methods: {
    initData() {
      getManagerChangeList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.count = res.num;
        }
      });
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    },
  },
  created() {
      let id = this.$route.query.id;
      if(id) this.queryParams.project_id = id;
    this.initData();
  },
};

const columns = [
  {
    prop: "project_name",
    label: "项目名称",
    width: "",
    minWidth: "200",
    align: "",
  },
  {
    prop: "person_type",
    label: "管理岗位",
    width: "",
    minWidth: "80",
    align: "",
  },
  {
    prop: "before_person_name",
    label: "原人员姓名",
    width: "before_person_id",
    minWidth: "80",
    align: "",
  },
  {
    prop: "before_person_id",
    label: "原人员身份证号",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "now_person_name",
    label: "现人员姓名",
    width: "",
    minWidth: "80",
    align: "",
  },
  {
    prop: "now_person_id",
    label: "现人员身份证号",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "change_date",
    label: "变更日期",
    width: "",
    minWidth: "100",
    align: "",
  },
];
</script>

<style lang="scss" scoped=""></style>
